import request from "@/api/inedx";

//登录接口
export const LoginApi = (data: LoginApiRequest): Promise<OwnAxiosResponse<LoginApiResponse>> => {
  return request.post('/api/user/login', data)
}

//获取用户信息
export const getUserInfoApi = (): Promise<OwnAxiosResponse<GetUserInfoApiResponse>> => {
  return request.get('/api/user/getCurrentUserInfo')
}

//获取用户角色
export const getUserRoleDetailApi = (currentUserId: number): Promise<OwnAxiosResponse<GetUserRoleResponse>> => {
  return request.get(`/api/user/role/detail/${currentUserId}`)
}

//保存用户角色
export const saveUserRoleApi = (data: SaveUserRoleRequest): Promise<OwnAxiosResponse<null>> => {
  return request.post('/api/user/role/save', data)
}

//退出登录
export const layoutApi = (): Promise<OwnAxiosResponse<null>> => {
  return request.post('/api/user/layout')
}

export const deleteUserApi = (userId: number | string): Promise<OwnAxiosResponse<boolean>> => {
  return request.delete(`/api/user/delete/${userId}`)
}

export const batchDeleteUserApi = (userIds: string): Promise<OwnAxiosResponse<boolean>> => {
  return request.post(`/api/user/batchDelete`, { userIds })
}

//修改用户状态
export const updateUserStatusApi = (userId: number | string, status: boolean): Promise<OwnAxiosResponse<boolean>> => {
  return request.put(`/api/user/updateStatus/${userId}`, { status })
}